<template>
  <base-breadcrumb>

      <a-card :body-style="{ padding: '24px 32px' }" :bordered="false">
        <title-name title="周计划列表"></title-name>
        <div class="table-operator">
          <a-button type="primary" icon="plus" @click="saveInfo()">保存信息</a-button>
          <a-button type="primary" :disabled="level != 4 || selectedRow.isMonthWeekCreated == false" @click="deleteNode()">删除节点</a-button>
          <a-button type="primary" :disabled="level != 4" @click="handleAddSame">新增同级节点</a-button>
          <!--<a-button type="primary" @click="handleAddDown">新增下级节点</a-button>-->
          <a-button type=""  @click="moveOneDay">前移一天</a-button>
          <!--<a-button type=""  @click="">全部恢复</a-button>-->
          <!--<a-button type=""  @click="">回撤</a-button>-->
        </div>

        <div class="pub-table-select-count">
          <a-icon type="info-circle" theme="twoTone"/>
          <span style="margin-right: 12px">
           项目名称：<span class="totalNum">{{deltailsTotal.projectName}}</span> |
           当前进行周计划：<span class="totalNum">{{ deltailsTotal.planTime}} </span> |
           本周需进行节点总数：<span class="totalNum">{{ deltailsTotal.conductTotal}} </span> 个 |
           本周计划开始节点数：<span class="totalNum">{{ deltailsTotal.startTotal}} </span> 个 |
           本周计划结束节点数：<span class="totalNum">{{ deltailsTotal.endTotal}} </span> 个 |
           延期到本周节点数：<span class="totalNum">{{ deltailsTotal.delayTotal}} </span> 个
        </span>
        </div>

        <a-table :pagination="false" :scroll="{ x: 2400}"  row-key="id" :columns="columns"  :rowClassName="rowClassNames"  :expandIconColumnIndex="2" :defaultExpandAllRows="true" :data-source="datas"  :customRow="selectRow" >

          <template slot="num" slot-scope="text, record, index">
            <span v-if="record.promptLights == 1&&record.promptLights!=null "> <img src="../../../assets/icons/yellowLight.png" width="20" hight="20"/></span>
            <span v-if="record.promptLights == 2&&record.promptLights!=null"> <img src="../../../assets/icons/redLight.png" width="20" hight="20"/></span>
            <span v-if="record.statusLights == 1&&record.statusLights!=null"> <div style="background: rgba(224, 244, 223, 1);width: 40px;height: 20px"></div> </span>
            <span v-if="record.statusLights == 2&&record.statusLights!=null"> <div style="background: rgba(251, 230, 232, 1);width: 40px;height: 20px"></div> </span>
            <span v-if="record.statusLights == 3&&record.statusLights!=null"> <div style="background: rgba(240, 153, 164, 1);width: 40px;height: 20px"></div> </span>
          </template>

          <template slot="name" slot-scope="text, record">
            <span v-if="record.level != 4 && record.isMonthWeekCreated == false "><ellipsis :length="20" tooltip>{{record.name}}</ellipsis></span>
            <BaseInput  type="textarea"  style="height:45px;width:300px"  v-if="record.level != 4 && record.isMonthWeekCreated == true && record.statusCode !=3" @blur="onCellChangeName" :value="record.name"  :text="text" placeholder='请输入'/>
          </template>

          <template slot="businessMatters" slot-scope="text, record">
            <span v-if=" record.level==4 && record.isMonthWeekCreated == false ">
               <ellipsis :length="40" tooltip>{{record.businessMatters}} </ellipsis>
            </span>
            <BaseTextarea   v-if="record.level==4 && record.isMonthWeekCreated == true && record.statusCode !=3 " @blur="onCellChangeBusiness" v-model="record.businessMatters"  :text="text" placeholder='请输入'/>
          </template>

            <template slot="controLevel" slot-scope="text, record">
                <span v-if="record.level==4 && record.isMonthWeekCreated == false ">{{record.controlLevelName}}</span>
                <cell @changes="onCellChangeControLevel" style="width: 300px;" v-if="record.level==4 && record.isMonthWeekCreated == true && record.statusCode !=3" formType="select"  :value="record.controlLevelId"  :text="record.controlLevelId" >
                    <a-select-option  v-for="item in nodeControls" :disabled="item.controlLevelId == 1 || item.controlLevelId== 2" :key="item.controlLevelId"  :value="item.controlLevelId">{{item.controlLevelName}}</a-select-option>
                </cell>
            </template>

            <!--<template slot="duration" slot-scope="text, record">-->
                <!--<span v-if="record.level==4 && record.isMonthWeekCreated == false ">{{record.duration}}</span>-->
                <!--<BaseInput v-if="record.level==4 && record.isMonthWeekCreated == true " @blur="onCellChangeDuration" :value="record.duration"  :text="text" placeholder='请输入'/>-->
            <!--</template>-->

          <template slot="startTime" slot-scope="text, record">
            <a-date-picker :allowClear="false" v-if="record.level==4 && record.statusCode !=3" @change="handleChangeStart"  placeholder='请输入日期' :value="record.startTime" :text="text"/>
          </template>

          <template slot="endTime" slot-scope="text, record">
            <a-date-picker :allowClear="false" v-if="record.level==4 && record.statusCode !=3" @change="handleChangeEnd"  placeholder='请输入日期' :value="record.endTime" :text="text"/>
          </template>

          <template slot="completeStandard" slot-scope="text, record">
            <a-tooltip placement="topLeft" :title="text">
            <span v-if="record.level==4 && record.isMonthWeekCreated == false ">{{record.completeStandard}}</span>
            </a-tooltip>
            <BaseTextarea  v-if="record.level==4 && record.isMonthWeekCreated == true && record.statusCode !=3"   @blur="handleChangeStandard" v-model="record.completeStandard" :text="text" placeholder='请输入'/>
          </template>

          <template slot="verifyDoc" slot-scope="text, record">
            <a-tooltip placement="topLeft" :title="text">
            <span v-if="record.level==4 && record.isMonthWeekCreated == false ">{{record.verifyDoc}}</span>
            </a-tooltip>
            <BaseTextarea  v-if="record.level==4 && record.isMonthWeekCreated == true && record.statusCode !=3"   @blur="handleChangeValidations" v-model="record.verifyDoc" :text="text" placeholder='请输入'/>
          </template>

          <template slot="firstResponsible" slot-scope="text, record">
            <a-tooltip placement="topLeft" @visibleChange="getDatas(record.firstResId)"  :title="infos">
              <span v-if="record.isMonthWeekCreated == false">{{record.firstResponsible}}</span>
              <span v-if="record.level==4 && record.isMonthWeekCreated == true  && record.firstResponsible != null">{{record.firstResponsible}}</span>
              <a  v-if="record.level==4 && record.isMonthWeekCreated == true  && record.firstResponsible != null && record.statusCode !=3"    @click="handleBind(record)"> (重新选择)</a>
              <a  v-if="record.level==4 && record.isMonthWeekCreated == true && record.firstResponsible==null && record.statusCode !=3"   @click="handleBind(record)">选择第一责任人</a>
            </a-tooltip>
          </template>

          <template slot="responsible" slot-scope="text, record">
            <a-tooltip placement="topLeft" @visibleChange="getPosts(record.responsibleId)"  :title="pensonalPosts">
            <span v-if="record.isMonthWeekCreated == false">{{record.responsible}}</span>
              <a-select @focus="getOrganizePeopleList"  :getPopupContainer="getPopupContainer"   v-if="record.level==4 && record.isMonthWeekCreated == true && record.statusCode !=3"    placeholder="请选择" v-model="record.responsible" style="width:100px" @change="handleChangeEngineer">
                <a-spin v-if="loading" slot="notFoundContent" size="small" />
                <a-select-option v-for="item in responsLists" :key="item.employeeId" :value="item.employeeId">{{item.employeeName}}</a-select-option>
              </a-select>
            </a-tooltip>
            <!--<BaseInput  v-if="record.level==4"  @blur="handleChangeEngineer" :value="record.responsiblEngineer" :text="text" placeholder='请输入'/>-->
          </template>


        </a-table>

        <add-level
                ref="createModal"
                :visible="visible"
                :model="mdl"
                @cancel="handleCancel"
                @ok="handleOk"/>
      </a-card>
    <modal   :id="currentId"  :orgQuery="orgQuery" :screening="screening"   :visible="bindOrgVisible" @handleCancelFirstRes="handleCancelFirstRes" @handleOk="handlefirstRes"></modal>

    <div class="page-btn-right-top">
    <!-- <div style="float: right;margin-bottom: 20px"> -->
      <a-button type="primary" class="ml12" :loading="loading" @click="submit">提交</a-button>
      <a-button type="primary" class="ml12" @click="goBack">关闭</a-button>
    </div>
  </base-breadcrumb>
</template>

<script>
  import {  Ellipsis } from '@/components'
  import FooterToolBar from '@/components/FooterToolbar'
  import addLevel from './addLevel'
  import { editMonthPlan,addMonthPlanSameNode,addMonthPlanDownNode, moveMonthPlanOneDay , deleteMonthNode} from '@/api/construction/monthPlan'
  import { weekPlanAudit} from '@/api/construction/weekPlan'
  import { getStaffAll } from '@/api/subassembly/TreeSelectOrganization'
  import { employeesDetail } from '@/api/material/assets/parameter'
  import { getWeekPlanDetails } from '@/api/construction/weekPlan'
  import { getProjectJobsList } from '@/api/project/projectsJobs'
  import { getConstructionsList } from '@/api/construction'
  import modal from '@/components/SelectJobs'
  import { getOrganizePeopleList,getOrgUserPosts } from '@/api/commons'
  import Vue from 'vue'
  import { getProjects } from '@/api/construction/planInput'

export default {
  name: 'StandardList',
  components: {
    addLevel,
    FooterToolBar,
    Ellipsis,
    modal
  },
  props: {
    text: String
  },

  data() {
    return {
      loading: false,
      infos:[],
      pensonalPosts:[],
      nodeControls:[], // 管控级别
      posts:[ ],
      columns:'',
      visible: false,
      mdl: null,
      selectedRowParent:null,
      currentId:'',
      editingKey:'',
      projectName:'',
      projectId:'',
      responsLists:[],
      datas:[],
      selectId:'',
      level:0,
      selectedRow:{},
      deltailsTotal:{},
      editData:{},
      startTime:'',   // 开始时间
      endTime:'',      // 结束时间

      orgQuery: { },
      screening: true,
      bindOrgVisible:false,
      id:'',
      statusCode:'',

    }
  },
  created() {
    const userInfo = Vue.getAcloudProvider().getUserInfo()
    this.currentId = userInfo.id
    this.columns = this.getColumns()
    this.id = this.$route.query.id
    this.statusCode = this.$route.query.statusCode
    this.getConstructionsList()
    this.getProjectJobsList()
    this.getWeekPlanDetails()
  },
  computed: {

  },
  methods: {
    // 查询第一责任人 姓名 电话 岗位
    getDatas(val){
      let that = this

      that.infos = []

      // 根据岗位id 查询人员的电话 姓名
      if(val !='' && val!=null ){
        getStaffAll({postId:val}).then(res=>{
          if(res.data && res.data.length > 0){
            let arr = []
            res.data.forEach(function(obj,i) {
              let item = {}
              item.name = obj.name
              item.phone = obj.phone

              arr.push(item)
            })

            var arrys = arr.map(function(objs,index){
              return objs.name + ',' + objs.phone;
            }).join(",");
            that.infos = arrys

          }
        })
      }




    },

    // 查询直接责任人 电话 岗位
    getPosts(val){
      let that = this

      that.pensonalPosts = []

      // 根据岗位id 查询人员的电话 姓名
      if(val !='' && val != null){
        getOrgUserPosts({employeeId:val}).then(ress=>{
          that.pensonalPosts = [ress.data]
        })
      }




    },
    deleteNode(){
      let _this = this

      _this.$confirm({
        title: '删除节点',
        content: '确定删除新增节点吗？',
        onOk() {
          deleteMonthNode({id:_this.selectedRow.id}).then(res=>{
            if(res.code == 200 || res.data.code == 200){
              _this.getWeekPlanDetails()
            }
          })
        },
        onCancel() {},
      });
    },
      handleBind(){
        this.bindOrgVisible = true
      },
      handleCancelFirstRes(){
        this.bindOrgVisible = false
      },

    handlefirstRes(value){
      this.bindOrgVisible = false
      let data={
        id:this.selectedRow.id,
        firstResId:value.jobsSelectedId,
        firstResponsible:value.jobsSelectedName,
      }
      editMonthPlan(data).then((res)=>{
        if(res){
          this.getWeekPlanDetails()
        }
      })
    },
      getPopupContainer(triggerNode){
        return  triggerNode.parentNode
      },
      getProjects(id) {
          const params = {
              projectIds: [id],
          }
          getProjects(params).then((res) => {
            console.log( res.data )
              this.orgQuery.ids = res.data[0].orgId
          })
      },
      // 直接责任人查询
      getOrganizePeopleList(){
        this.loading=true
        getOrganizePeopleList({id:this.projectId}).then(res=>{
          this.responsLists = res.data
          this.loading=false
        })
      },
    getConstructionsList(){
      getConstructionsList({pageNo:1,pageSize:50}).then(res=>{
        this.projectName = res.data.projectName
        this.projectId = res.data.projectId
        if(res.code == 200){
          let arr = res.data
          let arrys = []
          arr.forEach((item,i)=>{
            let obj ={}
            obj.controlLevelId = parseInt(item.controlLevelId)
            obj.controlLevelName =  item.controlLevelName
            arrys.push(obj)
          })
          this.nodeControls = arrys
        }
      })
    },
    getProjectJobsList(){
      getProjectJobsList().then(res=>{
        this.posts = res.data
      })
    },
    getWeekPlanDetails(){

      let that = this;
      const findSelectedRow = (children)=>{
        children.some((c)=>{
          if(c.id===that.selectedRow.id){
            that.selectedRow = c;
            return true
          }
          if(c.children&&c.children.length>0){
            return findSelectedRow(c.children)
          }
          return false
        })
      }

      getWeekPlanDetails(that.$route.query.id).then(res=>{
        that.datas = res.data.list
        that.deltailsTotal = res.data
        that.projectId = res.data.projectId
        that.getProjects(res.data.projectId)
        if(that.selectedRow.id){
          findSelectedRow(that.datas)
        }
      })
    },
    getColumns(){
      let rowIndex = 1
      return [
        {
          title: '',
          dataIndex: 'num',
          width: 60,
          scopedSlots: { customRender: 'num' },
        },
        {
          title: '编号',
          width: 60,
          dataIndex: 'sortNum',
        },
        {
          title: '阶段/类别',
          dataIndex: 'name',
          width:370,
          scopedSlots: { customRender: 'name' }
        },
        {
          title: '业务事项',
          dataIndex: 'businessMatters',
          className: 'column-date',
          width:300,
          scopedSlots: { customRender: 'businessMatters' }
        },
        {
          title: '管控级别',
          dataIndex: 'controLevel',
          width:150,
          className: 'column-date',
          scopedSlots: { customRender: 'controLevel' }
        },
        {
          title: '周期（天） ',
          dataIndex: 'duration',
          className: 'column-date',
          width:200,
          scopedSlots: { customRender: 'duration' }
        },
        {
          title: '计划开始时间',
          dataIndex: 'startTime',
          width:150,
          scopedSlots: { customRender: 'startTime' }
        },
        {
          title: '计划完成时间',
          dataIndex: 'endTime',
          className: 'column-date',
          width:150,
          scopedSlots: { customRender: 'endTime' }
        },
        {
          title: '实际完成时间',
          dataIndex: 'completeTime',
          className: 'column-date',
          width:150,
        },
        {
          title: '完成标准',
          dataIndex: 'completeStandard',
          className: 'column-date',
          width:420,
          ellipsis: true,
          scopedSlots: { customRender: 'completeStandard' }
        },
        {
          title: '验证资料',
          dataIndex: 'verifyDoc',
          className: 'column-date',
          width:300,
          ellipsis: true,
          scopedSlots: { customRender: 'verifyDoc' }
        },
        {
          title: '第一责任人',
          dataIndex: 'firstResponsible',
          width:300,
          className: 'column-date',
          scopedSlots: { customRender: 'firstResponsible' }
        },
        {
          title: '直接责任人',
          dataIndex: 'responsible',
          className: 'column-date',
          width:300,
          scopedSlots: { customRender: 'responsible' }
        },
        {
          title: '节点状态',
          className: 'column-date',
          width:150,
          dataIndex: 'statusName',
        },
      ]
    },

    onCellChangeName(e){
      this.selectedRow.name = e.target.value
      this.editData.id = this.selectedRow.id
      this.editData.name = e.target.value
      editMonthPlan(this.editData).then(res=>{
        if(res.code == 200){
          this.getWeekPlanDetails()
        }
      })
    },
    onCellChangeBusiness(e){
      console.log("valva",e.target.value)
      this.selectedRow.businessMatters = e.target.value
      this.editData.id = this.selectedRow.id
      this.editData.businessMatters = e.target.value
      editMonthPlan(this.editData).then(res=>{
        if(res.code == 200){
          this.getWeekPlanDetails()
        }
      })
    },
    onCellChangeControLevel(e){
      this.selectedRow.controLevel = e
      this.editData.id = this.selectedRow.id
      this.editData.controLevel = e
      editMonthPlan(this.editData).then(res=>{
        if(res.code == 200){
          this.getWeekPlanDetails()
        }
      })
    },
    onCellChangeDuration(e){
      this.selectedRow.duration = e.target.value
      this.editData.id = this.selectedRow.id
      this.editData.duration = e.target.value
      editMonthPlan(this.editData).then(res=>{
        if(res.code == 200){
          this.getWeekPlanDetails()
        }
      })
    },
    handleChangeStandard(e){
      this.editData.id = this.selectedRow.id
      this.editData.completeStandard = e.target.value
      editMonthPlan(this.editData).then(res=>{
        if(res.code == 200){
          this.getWeekPlanDetails()
        }
      })
    },

    handleChangeValidations(e){
      this.editData.id = this.selectedRow.id
      this.editData.verifyDoc = e.target.value
      editMonthPlan(this.editData).then(res=>{
        if(res.code == 200){
          this.getWeekPlanDetails()
        }
      })
    },

    handleResponsible(val){
      this.editData.id = this.selectedRow.id
      this.editData.responsible = val
      editMonthPlan(this.editData).then(res=>{
        if(res.code == 200){
          this.getWeekPlanDetails()
        }
      })
    },

    handleChangeRes(val){
      this.selectedRow.firstResponsible = val
      this.editData.id = this.selectedRow.id
      this.editData.firstResponsible = val
      editMonthPlan(this.editData).then(res=>{
        if(res.code == 200){
          this.getWeekPlanDetails()
        }
      })
    },

    handleChangeEngineer(value){
        this.editData.id = this.selectedRow.id
        this.editData.responsibleId = value
        let arr=this.responsLists.filter(item=>item.employeeId==value)
        this.editData.responsible = arr[0].employeeName
        editMonthPlan(this.editData).then(res=>{
        if(res.code == 200){
          this.getWeekPlanDetails()
        }
      })
    },


    handleChangeStart(val){
      this.startTime = val.format('YYYY-MM-DD')

      if(this.endTime != "" && this.selectedRow.endTime != "" ){
        this.endTime = this.selectedRow.endTime
        var startTime = new Date(this.startTime)
        var endTime = new Date(this.endTime)
        if( startTime > endTime ){
          this.$message.error("计划开始时间不能大于计划结束时间！")
          return;
        }
      }
      this.editData.id = this.selectedRow.id
      this.editData.startTime = val.format('YYYY-MM-DD')
      if(this.selectedRow.endTime == null){
        this.editData.endTime = null
      }
      editMonthPlan(this.editData).then(res=>{
        if(res.code == 200){
          this.getWeekPlanDetails()
        }
      })

    },
    handleChangeEnd(val){
      this.endTime = val.format('YYYY-MM-DD')


      if(this.endTime == ""){
        this.endTime = this.selectedRow.endTime
      }

      // 周期（天）
      var startTime = new Date(this.selectedRow.startTime)
      var endTime = new Date(this.endTime) // 修改时间
      let oldEndDate = new Date(this.selectedRow.oldEndDate)  // 生成时间

      if(this.selectedRow.isMonthWeekCreated == false){
        if(endTime > oldEndDate){
          this.$message.error("计划完成时间最大能调整到生成时间: "+ this.selectedRow.oldEndDate)
          val = this.selectedRow.endTime
          return;
        }
      }

      if(this.selectedRow.endTime != null && this.selectedRow.isMonthWeekCreated == false){
        var time1 = new Date(this.selectedRow.endTime) // 改过之前时间
        if(endTime > time1 && endTime > oldEndDate){
          this.$message.error("计划完成时间只能往前调整并且小于等于生成时间: " + this.selectedRow.oldEndDate)
          val = this.selectedRow.endTime
          return;
        }
      }

      if(endTime < startTime){
        this.$message.error("计划完成时间不能小于计划开始时间！")
        val = this.selectedRow.endTime
        return;
      }else{
        let iDays = parseInt(Math.abs(endTime.getTime()- startTime.getTime()) /1000/60/60/24);
        this.selectedRow.duration = iDays
      }

      this.editData.id = this.selectedRow.id
      this.editData.endTime = val.format('YYYY-MM-DD')
      if(this.selectedRow.startTime == null){
        this.editData.startTime = null
      }
      editMonthPlan(this.editData).then(res=>{
        if(res.code == 200){
          this.getWeekPlanDetails()
        }
      })

    },

    getParentNode(items){
      items.some(d=>{
        if( d.id ===this.selectedRow.parentId){
          this.selectedRowParent = d;
          return true;
        }
        if(d.children&&d.children.length>0){
          this.getParentNode(d.children)
        }
      })
    },
    handleOk() {
      const form = this.$refs.createModal.form
      form.validateFields((errors, values) => {
        if (!errors) {
          const newData = {
            key: 10,
            type: '',
            parentId:'',
            level:this.selectedRow.level,
            businessMatters: '',
            controLevel: '三级节点',
            duration: '20',
            startTime: '2020-09-01',
            endTime: '2020-09-08',
            completionTime: '2020-09-04',
            standard: '建设单位发放中标通知书或进场邀请函',
            validations: '中标通知书扫描件',
            responsible: '项目经理',
            responsiblEngineer: '某xx',
            feedback: '能按计划完成',
            statusCode: '计划完成',
            children:[]
          };


          if(values.level === "0"){   // 0是同级  1是下级

            this.getParentNode(this.datas)
            this.selectedRowParent.children.push(newData)

            this.visible = false

          }else if(values.level === "1" && this.level !=4) {

            const newData1 = {
              key: 10,
              type: '',
              parentId:'',
              level:4,
              businessMatters: '项目任务',
              controLevel: '三级节点',
              duration: '20',
              startTime: '2020-09-01',
              endTime: '2020-09-08',
              completionTime: '2020-09-04',
              standard: '建设单位发放中标通知书或进场邀请函',
              validations: '中标通知书扫描件',
              responsible: '项目经理',
              responsiblEngineer: '某xx',
              feedback: '能按计划完成',
              statusCode: '计划完成',
            };
            this.selectedRow.children.push(newData1)
            this.visible = false

          }else{
            this.$message.error("四级节点不能新增下级！")
          }
        }
      })
    },

    handleCancel() {
      this.visible = false
      const form = this.$refs.createModal.form
      form.resetFields() // 清理表单数据（可不做）
    },

    selectRow(record){
      return {
        on: {
          click: () => {
            this.selectId = record.id
            this.level = record.level   // 当前选中是第几级
            this.selectedRow = record   // 当前行数据
            this.editData = record // 同步一下数据
            console.log("当前行数据：",this.selectedRow)
            this.columns = this.getColumns()  // 复制当前行属性数据
            this.rowClassNames(record)
          }
        }
      }
    },

    rowClassNames(record){
      if( this.selectId == record.id ){
        return 'clickRowStyle'
      }
    },

    saveInfo(){
      if(this.level == 0 || this.level != 4){
        this.$message.error("请先选中节点！")
        return;
      }
      this.$message.success("保存成功!")
      this.$multiTab.close(this.$route.fullpath)
    },
    // 提交审核
    submit(){
      let that = this;
      if(that.loading){
        return
      }
      that.loading = true
      weekPlanAudit({id:that.id}).then(res=>{
        if (res.data.code == 200 || res.code == 200) {
          that.loading = false
          that.$message.success("提交成功!")
          that.$multiTab.close(that.$route.fullpath)
        }
      }).catch(() => that.loading = false)

    },
    goBack(){
      this.$multiTab.close(this.$route.fullpath)
    },
    moveOneDay(){
      if( this.level == ''){
        this.$message.error("请先选中节点！")
      }else{
        this.editData.id = this.selectedRow.id
        this.editData.startTime = this.selectedRow.startTime
        this.editData.endTime = this.selectedRow.endTime
        moveMonthPlanOneDay(this.editData).then(res=>{
          if(res.code == 200){
            this.getWeekPlanDetails()
          }
        })
      }
    },
    // 新增同级节点
    handleAddSame(){
      let _this = this;

      if( _this.level == ''){
        _this.$message.error("请先选中节点！")
        return
      }

      if(_this.level != 4){
        _this.$message.error("工作包不可以新增！")
        return
      }else{
        _this.$confirm({
          title: '新增节点',
          content: '确定新增同级节点吗？',
          onOk() {
            _this.editData.planId  = _this.$route.query.id
            _this.editData.level  = _this.selectedRow.level
            _this.editData.id  = _this.selectedRow.id
            addMonthPlanSameNode(_this.editData).then(res=>{
              if(res.code == 200 || res.data.code == 200){
                _this.getWeekPlanDetails()
              }
            })
          },
          onCancel() {},
        });
      }




    },
    // 新增下级节点
    handleAddDown(){

      let _this = this;
      if( _this.level == ''){
        _this.$message.error("请先选中节点！")
        return
      }else if(_this.level != 3){
        _this.$message.error("只能新增三级工作包！")
        return
      } else if(_this.level == 4){
        _this.$message.error("四级节点不能新增下级！")
        return
      } else{
        _this.$confirm({
          title: '新增节点',
          content: '确定新增下级节点吗？',
          onOk() {
            _this.editData.planId  = _this.$route.query.id
            _this.editData.level  = _this.selectedRow.level
            _this.editData.id  = _this.selectedRow.id
            addMonthPlanDownNode(_this.editData).then(res=>{
              if(res.code == 200){
                _this.getWeekPlanDetails()
              }
            })

          },
          onCancel() {},
        });

      }
    },
  }
}
</script>

<style lang="less" scoped>
  /deep/ .ant-table-body  .clickRowStyle{
    background-color: rgb(230, 243, 252);
  }
  /deep/ .column-date.ant-table-row-cell-break-word {
    text-align: center !important;
  }
.wrapper-row {
  padding-left: 55px;
  font-weight: bold;
  letter-spacing: 1px;
}

/deep/ .ant-form-item label {
  font-size: 12px;
}

/deep/ .ant-btn {
  border-radius: 5px;
}

/deep/ .ant-calendar-picker-input.ant-input {
  width: 100%;
}

/deep/ .ant-input {
  /*width: 70%;*/
  border-radius: 5px;
}

/deep/ .ant-calendar-picker {
  width: 100%;
  border-radius: 5px;
}

/deep/ .ant-card.ant-card-bordered {
  border-radius: 5px;
}

.ant-avatar-lg {
  width: 48px;
  height: 48px;
  line-height: 48px;
}

.list-content-item {
  color: rgba(0, 0, 0, 0.45);
  display: inline-block;
  vertical-align: middle;
  font-size: 14px;
  margin-left: 40px;
  span {
    line-height: 20px;
  }
  p {
    margin-top: 4px;
    margin-bottom: 0;
    line-height: 22px;
  }
}

.title-name {
  border-left: 5px solid #1890ff;
  font-weight: bold;
  font-size: 16px;
  margin-bottom: 20px;
  padding-left: 15px;
  height: 20px;
  line-height: 20px;
}

/deep/ .table-page-search-wrapper .ant-form-inline .ant-row .ant-col.ant-col-sm-24.ant-col-md-12 {
  padding-left: 80px;
}
/deep/ .ant-table-tbody > tr > td{
  padding:5px !important
}
</style>

